#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
typedef long long ll;
    vector<bool> findAnswer(int n, vector<vector<int>>& edges) {
        vector<vector<tuple<int,ll,int>>> g(n);
        for(int i=0;i<edges.size();i++)
        {
            auto& e=edges[i];
            g[e[0]].emplace_back(e[1],e[2],i);
            g[e[1]].emplace_back(e[0],e[2],i);
        }
        priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<>> q;
        vector<ll> d(n,LLONG_MAX);
        d[0]=0;
        q.emplace(0,0);
        while(!q.empty())
        {
            auto [d_x,x]=q.top();
            q.pop();
            if(d_x>d[x]) continue;
            for(auto& [y,d_y,_]:g[x])
            {
                int new_d=d_y+d[x];
                if(new_d<d[y])
                {
                    d[y]=new_d;
                    q.emplace(d[y],y);
                }
            }
        }
        vector<bool> ans(edges.size());
        if(d[n-1]==LLONG_MAX) return ans;
        vector<bool> visit(n);
        function<void(int)> dfs=[&](int x)
        {
            visit[x]=true;
            for(auto& [y,d_y,i]:g[x])
            {
                if(d_y+d[y]!=d[x]) continue;
                ans[i]=true;
                if(!visit[y]) dfs(y);
            }
        };
        dfs(n-1);
        return ans;
    }
};